package app.htby.utils;

import java.util.HashSet;
import java.util.Set;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class KafkaConsumeUtils {
	/** topic数量，从0开始 */
	public static int topicCount = 0;
	/** kafka主题集合 */
	public static Set<String> topicSet= new HashSet<String>();
	public static String beanId = "Consumer_" + KafkaConsumeUtils.topicCount;//设置id
	
	/** kafka消费者配置 */
	public static String bootstrapServers = "192.168.3.40:9092";
	public static String enable_auto_commit = "true";
	public static String auto_offset_reset = "latest";
	public static String session_timeout_ms = "30000";
	public static String auto_commit_interval_ms = "1000";
	public static String key_deserializer = "org.apache.kafka.common.serialization.StringDeserializer";
	public static String value_deserializer = "org.apache.kafka.common.serialization.StringDeserializer";
	
	public static String group_id = "";
	public static String dis_group_id = "dis_web_data_info";//分发系统 组
	
	/** 是否消费分发数据 */
	public static boolean IS_CONSUMER_DIS = true;
	
	@Value("${kafka.disServerConfig.group.id}")
	public void setDisGroupId(String dis_group_id) {
		KafkaConsumeUtils.dis_group_id = dis_group_id;
	}
	
	@Value("${kafka.consume.group.id}")
	public void setGroupId(String group_id) {
		KafkaConsumeUtils.group_id = group_id;
	}
	
	@Value("${kafka.consume.bootstrap.servers}")
	public void setBootstrapServers(String bootstrapServers) {
		KafkaConsumeUtils.bootstrapServers = bootstrapServers;
	}

	@Value("${kafka.consume.enable.auto.commit}")
	public void setEnableAutoCommit(String enable_auto_commit) {
		KafkaConsumeUtils.enable_auto_commit = enable_auto_commit;
	}

	@Value("${kafka.consume.auto.offset.reset}")
	public void setAutoOffsetReset(String auto_offset_reset) {
		KafkaConsumeUtils.auto_offset_reset = auto_offset_reset;
	}

	@Value("${kafka.consume.session.timeout.ms}")
	public void setSessionTimeoutMs(String session_timeout_ms) {
		KafkaConsumeUtils.session_timeout_ms = session_timeout_ms;
	}

	@Value("${kafka.consume.auto.commit.interval.ms}")
	public void setAutoCommitIntervalMs(String auto_commit_interval_ms) {
		KafkaConsumeUtils.auto_commit_interval_ms = auto_commit_interval_ms;
	}

	@Value("${kafka.consume.value.deserializer}")
	public void setValueDeserializer(String value_deserializer) {
		KafkaConsumeUtils.value_deserializer = value_deserializer;
	}

	@Value("${kafka.consume.key.deserializer}")
	public void setKeyDeserializer(String key_deserializer) {
		KafkaConsumeUtils.key_deserializer = key_deserializer;
	}
}
